package com.openbravo.pos.printer.escpos;

import com.openbravo.pos.printer.TicketPrinterException;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.NoSuchPortException;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;
import gnu.io.UnsupportedCommOperationException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

public class PrinterWritterRXTX extends PrinterWritter
{
  private CommPortIdentifier m_PortIdPrinter;
  private CommPort m_CommPortPrinter;
  private String m_sPortPrinter;
  private OutputStream m_out;

  public PrinterWritterRXTX(String paramString)
    throws TicketPrinterException
  {
    this.m_sPortPrinter = paramString;
    this.m_out = null;
  }

  protected void internalWrite(byte[] paramArrayOfByte)
  {
    try
    {
      if (this.m_out == null)
      {
        this.m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(this.m_sPortPrinter);
        this.m_CommPortPrinter = this.m_PortIdPrinter.open("PORTID", 2000);
        this.m_out = this.m_CommPortPrinter.getOutputStream();
        if (this.m_PortIdPrinter.getPortType() == 1)
          ((SerialPort)this.m_CommPortPrinter).setSerialPortParams(9600, 8, 1, 0);
      }
      this.m_out.write(paramArrayOfByte);
    }
    catch (NoSuchPortException localNoSuchPortException)
    {
      System.err.println(localNoSuchPortException);
    }
    catch (PortInUseException localPortInUseException)
    {
      System.err.println(localPortInUseException);
    }
    catch (UnsupportedCommOperationException localUnsupportedCommOperationException)
    {
      System.err.println(localUnsupportedCommOperationException);
    }
    catch (IOException localIOException)
    {
      System.err.println(localIOException);
    }
  }

  protected void internalFlush()
  {
    try
    {
      if (this.m_out != null)
        this.m_out.flush();
    }
    catch (IOException localIOException)
    {
      System.err.println(localIOException);
    }
  }

  protected void internalClose()
  {
    try
    {
      if (this.m_out != null)
      {
        this.m_out.flush();
        this.m_out.close();
        this.m_out = null;
        this.m_CommPortPrinter = null;
        this.m_PortIdPrinter = null;
      }
    }
    catch (IOException localIOException)
    {
      System.err.println(localIOException);
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.escpos.PrinterWritterRXTX
 * JD-Core Version:    0.6.0
 */